<?php $this->load->view("common/page_header");?>
	<?php $this->load->view("common/top_banner");?>
	<?php $this->load->view("common/header");?>
	<div id="body_main">
		<?php $this->load->view('common/user_top');?>
		<div class="top_border">
			<div class="arrow_up" style="left:90px"></div>
		</div>
		
		<div id="body_content" class="user_info">
			<?php $this->load->view("common/user_info_table");?>
			
			<div class="margin_top15">
				<?php $this->load->view("common/user_info_navigator");?>
				<div class="user_info_content">
					<table class="b_table text_left_table user_address_table" width="100%"  cellspacing="0">
						<tr>
							<td width="65">手机：</td>
							<td>
								<span><?php echo isset($contact['mobile']) ? $contact['mobile'] : '';?></span>
								<?php if ($is_author) {?>
								<input class="hide" type="text" value="<?php echo isset($contact['mobile']) ? $contact['mobile'] : '';?>" />
								<input class="hide" type="button" value="提交" onclick="submit_personal_info(this, 'mobile');" />
								<a href="javascript:void(0)" onclick="edit_peronal_info(this)" >[编辑]</a>
								<?php }?>
							</td>
						</tr>
						<tr>
							<td>电话：</td>
							<td>
								<span><?php echo isset($contact['telephone']) ? $contact['telephone'] : '';?></span>
								<?php if ($is_author) {?>
								<input class="hide" type="text" value="<?php echo isset($contact['telephone']) ? $contact['telephone'] : '';?>" />
								<input class="hide" type="button" value="提交" onclick="submit_personal_info(this, 'telephone');" />
								<a href="javascript:void(0)" onclick="edit_peronal_info(this)" >[编辑]</a>
								<?php }?>
							</td>
						</tr>
						<tr>
							<td>信箱：</td>
							<td>
								<span><?php echo isset($contact['email']) ? $contact['email'] : ''; ?></span>
								<?php if ($is_author) {?>
								<input class="hide" type="text" value="<?php echo isset($contact['email']) ? $contact['email'] : ''; ?>" />
								<input class="hide" type="button" value="提交" onclick="submit_personal_info(this, 'email');" />
								<a href="javascript:void(0)" onclick="edit_peronal_info(this)" >[编辑]</a>
								<?php }?>
							</td>
						</tr>
						<tr>
							<td>QQ号：</td>
							<td>
								<span><?php echo isset($contact['qq']) ? $contact['qq'] : '';?></span>
								<?php if ($is_author) {?>
								<input class="hide" type="text" value="<?php echo isset($contact['qq']) ? $contact['qq'] : '';?>" />
								<input class="hide" type="button" value="提交" onclick="submit_personal_info(this, 'qq');" />
								<a href="javascript:void(0)" onclick="edit_peronal_info(this)" >[编辑]</a>
								<?php }?>
							</td>
						</tr>
						<tr>
							<td>博客：</td>
							<td>
								<span><?php echo isset($contact['blog']) ? $contact['blog'] : '';?></span>
								<?php if ($is_author) {?>
								<input class="hide" type="text" value="<?php echo isset($contact['blog']) ? $contact['blog'] : '';?>" />
								<input class="hide" type="button" value="提交" onclick="submit_personal_info(this, 'blog');" />
								<a href="javascript:void(0)" onclick="edit_peronal_info(this)" >[编辑]</a>
								<?php }?>
							</td>
						</tr>
					</table>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		
		<script>
			function edit_peronal_info(src) {
				var $this = $(src);
				var $parent = $this.parent();
				$parent.find('span, a').hide();
				$parent.find('input').show();
			}

			function submit_personal_info(src, type) {
				var $this = $(src);
				var $parent = $this.parent();
				var val = $parent.find('input[type=text]').val();
				
				$.post("/user/ajax_update", { "type": type, "val": val },function(data) {
					if (data == "1") {
						$parent.find('span').text(val);
						$parent.find('span, a').show();
						$parent.find('input').hide();
					} else {
						alert("服务器正忙，请稍候再试");
					}
				});
			}
		</script>
		<?php $this->load->view("common/footer");?>		
		
		<p class="center">Page rendered in {elapsed_time} seconds</p>
	</div>
	
<?php $this->load->view("common/page_footer");?>
